package com.xjcs.saplingplan.room.utils

import androidx.annotation.WorkerThread
import com.xjcs.saplingplan.MainApp
import com.xjcs.saplingplan.room.AppDatabase
import com.xjcs.saplingplan.room.bean.countdown.PlanCateBean

object PlanCateRoomUtils {

    private val planCateDao by lazy {
        AppDatabase.getInstance(MainApp.getAppContext()).planCateDao()
    }

    @WorkerThread
    fun insert(bean: PlanCateBean){
        planCateDao.insert(bean)
    }

    @WorkerThread
    fun insertList(beanList: MutableList<PlanCateBean>){
        planCateDao.insertList(beanList)
    }

    @WorkerThread
    fun getPlanCateBean(cateName: String): PlanCateBean? {
        return planCateDao.getPlanCateBean(cateName)
    }

    @WorkerThread
    fun deletePlanCateBean(cateBean: PlanCateBean) {
        return planCateDao.deleteItem(cateBean)
    }

    @WorkerThread
    fun getCateSortMax(userId: String): Int {
        return planCateDao.getCateSortMax(userId)
    }

    @WorkerThread
    fun getAllPlanCateList(userId: String): MutableList<PlanCateBean>{
        return planCateDao.getAllPlanCateList(userId)
    }

}